<%@page import="sedev.shopping.util.Paging"%>
<%@page import="sedev.shopping.business.LoaiSanPhamService"%>
<%@page import="sedev.shopping.entities.ListLoaiSanPham"%>
<%@page import="sedev.shopping.util.SedevUtil.ModeDisplay"%>
<%@page import="sedev.shopping.business.NhomSanPhamService"%>
<%@page import="sedev.shopping.entities.ListNhomSanPham"%>
<%@page import="sedev.shopping.util.SedevUtil"%>
<%@ include file="/init.jsp" %>
<%
	ListNhomSanPham listnhomsanpham = null;
	ListLoaiSanPham listloaisanpham = null;
	if("Guest".equals(SedevUtil.getGroupName(request))){
		listnhomsanpham = NhomSanPhamService.getListDataByAll(ModeDisplay.Display);
	}else{
		long ownerId = SedevUtil.getOwnerShopId(request);
		listloaisanpham = LoaiSanPhamService.getListDataByUser(ownerId, new Paging(), ModeDisplay.Display);
	}	
%>

<div class='sedev-vertical_menu'>
    <ul id='sedev_shopping_menu'>
    	<li>
    		<a href="<s:url action="index"></s:url>">
				<span><liferay-ui:message key="title-home" /></span>
			</a>
    	</li>
    </ul>
</div>
<div class="clr"></div>

<div id='shopping_treemenu' style='display:none'>
<%
if(listnhomsanpham != null && listnhomsanpham.size()>0){	
%>
	{"data":[
<%
	for(int index=0; index<listnhomsanpham.size(); ++index ){
%>
		<%if(index !=0 ) {%>
		,
		<%} %>
		{
			"id":"<%=listnhomsanpham.get(index).getId() %>"
			,"parentId":"<%=listnhomsanpham.get(index).getNhomSanPhamId() %>"
			,"name":"<%=listnhomsanpham.get(index).getTen() %>"
		}			
	<%}%>
		]
	,"link":"<s:url action="group"></s:url>&shopping_group"
	,"active":"1"
	}
<%}else{%>
		{"data":[
	<%
    	if(listloaisanpham != null && listloaisanpham.size()>0){
    %>    		
	    <%
	    	for(int index=0; index<listloaisanpham.size(); ++index ){
	    %>
	    		<%if(index !=0 ) {%>
					,
				<%} %>
				{
					"id":"<%=listloaisanpham.get(index).getId() %>"
					,"parentId":"0"
					,"name":"<%=listloaisanpham.get(index).getTen() %>"
				}
    		<%}%>
	    					
    	<%}%>
    	]
		,"link":"<s:url action="type"></s:url>&shopping_type"
		,"active":"1"
   	<%	if(SedevUtil.isOwner(request)){%>
    		,"manager":"<s:url action="product"></s:url>"	
    		,"title":"<liferay-ui:message key="label-manager" />"
   	<%} %>
		}
<%}%>

</div>
<script type="text/javascript">
<!--
	shopping.treeMenu('sedev_shopping_menu','shopping_treemenu');
	sedev.verticalMenu('sedev_shopping_menu','sedev_shopping_menu');	
//-->
</script>
